<?php
include_once("{$_SERVER['DOCUMENT_ROOT']}/CommonClasses/MySQLDAO.php");
include("AppsBean.php");

class AppsDAO extends MySQLDAO {
	protected function lookupSqlById($id) {
		switch($id) {
			case "SELECT":
				return "select AppSite,AppPath,AppID,AppName,AppPurpose,AppDescription from apps where AppID = ?";
				break;
			case "INSERT":
				return "insert into apps (AppSite,AppPath,AppID,AppName,AppPurpose,AppDescription) values (?,?,?,?,?,?)";
				break;
			case "UPDATE":
				return "update apps set AppSite = ?,AppPath = ?,AppID = ?,AppName = ?,AppPurpose = ?,AppDescription = ? where AppID = ?";
				break;
			case "DELETE":
				return "delete from apps where AppID = ?";
				break;
			default:
				return;
				break;
		}
	}

	protected function bindParameters($id,$paramBean) {
		switch($id) {
			case "SELECT":
				$params[0] = $this->bindString($paramBean->getAppID());
				break;
			case "INSERT":
				$params[0] = $this->bindString($paramBean->getAppSite());
				$params[1] = $this->bindString($paramBean->getAppPath());
				$params[2] = $this->bindString($paramBean->getAppID());
				$params[3] = $this->bindString($paramBean->getAppName());
				$params[4] = $this->bindString($paramBean->getAppPurpose());
				$params[5] = $this->bindString($paramBean->getAppDescription());
				break;
			case "UPDATE":
				break;
			case "DELETE":
				break;
		}
		return $params;
	}

	protected function loadBean($id,$row,$rows) {
		$bean = new AppsBean();
		switch($id) {
			case "SELECT":
				$bean->setAppSite($row['AppSite']);
				$bean->setAppPath($row['AppPath']);
				$bean->setAppID($row['AppID']);
				$bean->setAppName($row['AppName']);
				$bean->setAppPurpose($row['AppPurpose']);
				$bean->setAppDescription($row['AppDescription']);
				break;
		}
		array_push($rows,$bean);
		return $rows;
	}

	protected function getDbPropertiesFile($file="") {
    	try {
			parent::getDbPropertiesFile();
        }
		catch(Exception $e) {
			print('<br><br><span style="color:red;">There was an error loading the properties file!!</span>');
	        exit();
        }
	}
}
?>
